1 Effect of UPSTM-Based Decorrelation on Feature Discovery

1.0.1 Loading the libraries

library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)

op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)

1.1 Material and Methods

About Dataset This dataset is a copy of another Kaggle dataset which can be accessed here: https://www.kaggle.com/c/glioma-radiomics The difference is that I have provided ground truth for the test set (test_GT.csv).

The suffix “omics” in Medical Science is associated with analysis of big sets of features (e.g. Genomics, Proteomics). Radiomics are imaging features (e.g., first order and second order) extracted from Regions of Interest (ROI) in radiology images based on predefined functions and filters. Low grade gliomas (LGG) are a type of brain tumors. Astrocytes and Oligodendrocytes which are two types of brain cells, are considered as origins of LGG. Adult LGG are characterized by different mutations which is important to be correctly identified. With this dataset the goal is to determine if an ROI has 1p19q codeletion (Mutacion=1) or not(Mutacion=0). This plays a key role in predicting patient’s response to chemotherapy and their survival. The dataset provides 640 different radiomics features for each ROI. There are 105 ROIs in the training set and 45 ROIs in the test cohort.

1.2 The Data

https://www.kaggle.com/datasets/knamdar/radiomics-for-lgg-dataset?select=test_GT.csv


LGG_Data <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/train.csv")
LGG_DataTest <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/test.csv")
LGG_TestGT <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/test_GT.csv")
LGG_DataTest$Mutacion <- LGG_TestGT$Mutacion

LGG_Data <- rbind(LGG_Data,LGG_DataTest)

rownames(LGG_Data) <- LGG_Data$patientID
LGG_Data$patientID <- NULL

pander::pander(table(LGG_Data$Mutacion))
0 1
54 96

1.2.0.1 Standarize the names for the reporting

studyName <- "LGG"
dataframe <- LGG_Data
outcome <- "Mutacion"

TopVariables <- 10

thro <- 0.80
cexheat = 0.15

1.3 Generaring the report

1.3.1 Libraries

Some libraries

library(psych)
library(whitening)
library("vioplot")

1.3.2 Data specs

pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
rows col
150 640
pander::pander(table(dataframe[,outcome]))
0 1
54 96

varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]

largeSet <- length(varlist) > 1000

1.3.3 Scaling the data

Scaling and removing near zero variance columns and highly co-linear(r>0.99999) columns


  ### Some global cleaning
  sdiszero <- apply(dataframe,2,sd) > 1.0e-16
  dataframe <- dataframe[,sdiszero]

  varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
  tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
  dataframe <- dataframe[,tokeep]

  varlist <- colnames(dataframe)
  varlist <- varlist[varlist != outcome]


dataframe <- FRESAScale(dataframe,method="OrderLogit")$scaledData

1.4 The heatmap of the data


if (!largeSet)
{
  
  hm <- heatMaps(data=dataframe,
                 Outcome=outcome,
                 Scale=TRUE,
                 hCluster = "row",
                 xlab="Feature",
                 ylab="Sample",
                 srtCol=45,
                 srtRow=45,
                 cexCol=cexheat,
                 cexRow=cexheat
                 )
  par(op)
}

1.4.0.1 Correlation Matrix of the Data

The heat map of the data


if (!largeSet)
{

  par(cex=0.6,cex.main=0.85,cex.axis=0.7)
  #cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
  cormat <- cor(dataframe[,varlist],method="pearson")
  cormat[is.na(cormat)] <- 0
  gplots::heatmap.2(abs(cormat),
                    trace = "none",
  #                  scale = "row",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Original Correlation",
                    cexRow = cexheat,
                    cexCol = cexheat,
                     srtCol=45,
                     srtRow=45,
                    key.title=NA,
                    key.xlab="Pearson Correlation",
                    xlab="Feature", ylab="Feature")
  diag(cormat) <- 0
  print(max(abs(cormat)))
}

[1] 0.999999

1.5 The decorrelation


DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#> 
#>  Included: 633 , Uni p: 0.02929148 , Uncorrelated Base: 94 , Outcome-Driven Size: 0 , Base Size: 94 
#> 
#> 
 1 <R=1.000,w=  1,N=  399>, Top: 79( 9 )[ 1 : 79 : 0.975 ]( 79 , 278 , 0 ),<|>Tot Used: 357 , Added: 278 , Zero Std: 0 , Max Cor: 0.999
#> 
 2 <R=0.999,w=  1,N=  399>, Top: 25( 1 )[ 1 : 25 : 0.975 ]( 25 , 34 , 79 ),<|>Tot Used: 384 , Added: 34 , Zero Std: 0 , Max Cor: 0.999
#> 
 3 <R=0.999,w=  2,N=  174>, Top: 67( 1 )[ 1 : 67 : 0.950 ]( 63 , 86 , 104 ),<|>Tot Used: 448 , Added: 86 , Zero Std: 0 , Max Cor: 0.979
#> 
 4 <R=0.979,w=  2,N=  174>, Top: 25( 1 )[ 1 : 25 : 0.940 ]( 25 , 27 , 138 ),<|>Tot Used: 460 , Added: 27 , Zero Std: 0 , Max Cor: 0.957
#> 
 5 <R=0.957,w=  2,N=  174>, Top: 20( 1 )[ 1 : 20 : 0.929 ]( 20 , 25 , 148 ),<|>Tot Used: 481 , Added: 25 , Zero Std: 0 , Max Cor: 0.959
#> 
 6 <R=0.959,w=  2,N=  174>, Top: 2( 1 )[ 1 : 2 : 0.930 ]( 2 , 2 , 158 ),<|>Tot Used: 481 , Added: 2 , Zero Std: 0 , Max Cor: 0.928
#> 
 7 <R=0.928,w=  3,N=  181>, Top: 71( 1 )[ 1 : 71 : 0.888 ]( 65 , 81 , 158 ),<|>Tot Used: 529 , Added: 81 , Zero Std: 0 , Max Cor: 0.976
#> 
 8 <R=0.976,w=  3,N=  181>, Top: 8( 1 )[ 1 : 8 : 0.888 ]( 8 , 10 , 195 ),<|>Tot Used: 536 , Added: 10 , Zero Std: 0 , Max Cor: 0.914
#> 
 9 <R=0.914,w=  4,N=  182>, Top: 67( 2 )=[ 2 : 67 : 0.854 ]( 62 , 90 , 199 ),<|>Tot Used: 570 , Added: 90 , Zero Std: 0 , Max Cor: 0.982
#> 
 10 <R=0.982,w=  4,N=  182>, Top: 15( 1 )[ 1 : 15 : 0.841 ]( 15 , 16 , 232 ),<|>Tot Used: 573 , Added: 16 , Zero Std: 0 , Max Cor: 0.990
#> 
 11 <R=0.990,w=  5,N=   41>, Top: 17( 1 )[ 1 : 17 : 0.800 ]( 17 , 18 , 244 ),<|>Tot Used: 575 , Added: 18 , Zero Std: 0 , Max Cor: 0.799
#> 
 12 <R=0.000,w=  5,N=   41>
#> 
 [ 12 ], 0.7993728 Decor Dimension: 575 . Cor to Base: 268 , ABase: 53 , Outcome Base: 0 
#> 
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]

pander::pander(sum(apply(dataframe[,varlist],2,var)))

810

pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))

212

pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))

4.91

pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))

3.34

1.5.1 The decorrelation matrix


if (!largeSet)
{

  par(cex=0.6,cex.main=0.85,cex.axis=0.7)
  
  UPSTM <- attr(DEdataframe,"UPSTM")
  
  gplots::heatmap.2(1.0*(abs(UPSTM)>0),
                    trace = "none",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Decorrelation matrix",
                    cexRow = cexheat,
                    cexCol = cexheat,
                   srtCol=45,
                   srtRow=45,
                    key.title=NA,
                    key.xlab="|Beta|>0",
                    xlab="Output Feature", ylab="Input Feature")
  
  par(op)
}

1.6 The heatmap of the decorrelated data

if (!largeSet)
{

  hm <- heatMaps(data=DEdataframe,
                 Outcome=outcome,
                 Scale=TRUE,
                 hCluster = "row",
                 cexRow = cexheat,
                 cexCol = cexheat,
                 srtCol=45,
                 srtRow=45,
                 xlab="Feature",
                 ylab="Sample")
  par(op)
}

1.7 The correlation matrix after decorrelation

if (!largeSet)
{

  cormat <- cor(DEdataframe[,varlistc],method="pearson")
  cormat[is.na(cormat)] <- 0
  
  gplots::heatmap.2(abs(cormat),
                    trace = "none",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Correlation after IDeA",
                    cexRow = cexheat,
                    cexCol = cexheat,
                     srtCol=45,
                     srtRow=45,
                    key.title=NA,
                    key.xlab="Pearson Correlation",
                    xlab="Feature", ylab="Feature")
  
  par(op)
  diag(cormat) <- 0
  print(max(abs(cormat)))
}

[1] 0.7993728

1.8 U-MAP Visualization of features

1.8.1 The UMAP based on LASSO on Raw Data

classes <- unique(dataframe[,outcome])
raincolors <- rainbow(length(classes))
names(raincolors) <- classes
datasetframe.umap = umap(scale(dataframe[,varlist]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
text(datasetframe.umap$layout,labels=dataframe[,outcome],col=raincolors[dataframe[,outcome]+1])

1.8.2 The decorralted UMAP


datasetframe.umap = umap(scale(DEdataframe[,varlistc]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After IDeA",t='n')
text(datasetframe.umap$layout,labels=DEdataframe[,outcome],col=raincolors[DEdataframe[,outcome]+1])

1.9 Univariate Analysis

1.9.1 Univariate



univarRAW <- uniRankVar(varlist,
               paste(outcome,"~1"),
               outcome,
               dataframe,
               rankingTest="AUC")

100 : wavelet.HHH_firstorder_10Percentile 200 : wavelet.HHL_firstorder_Uniformity 300 : wavelet.HLH_glcm_Imc1 400 : wavelet.HLL_gldm_GrayLevelVariance 500 : wavelet.LHH_glrlm_LongRunLowGrayLevelEmphasis
600 : wavelet.LHL_glszm_LargeAreaHighGrayLevelEmphasis




univarDe <- uniRankVar(varlistc,
               paste(outcome,"~1"),
               outcome,
               DEdataframe,
               rankingTest="AUC",
               )

100 : La_wavelet.HHH_firstorder_10Percentile 200 : La_wavelet.HHL_firstorder_Uniformity 300 : wavelet.HLH_glcm_Imc1 400 : La_wavelet.HLL_gldm_GrayLevelVariance 500 : La_wavelet.LHH_glrlm_LongRunLowGrayLevelEmphasis
600 : wavelet.LHL_glszm_LargeAreaHighGrayLevelEmphasis

1.9.2 Final Table


univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")

##topfive
topvar <- c(1:length(varlist)) <= TopVariables
pander::pander(univarRAW$orderframe[topvar,univariate_columns])
  caseMean caseStd controlMean controlStd controlKSP ROCAUC
original_firstorder_Skewness 0.34095 0.841 -0.679 0.99 0.840 0.780
original_glcm_ClusterShade 0.38451 1.104 -0.841 1.42 0.509 0.755
wavelet.HLL_glcm_ClusterShade -0.47639 1.307 0.884 1.72 0.538 0.737
wavelet.HLL_firstorder_Skewness -0.30857 0.904 0.509 1.10 0.534 0.736
original_firstorder_Median -0.22280 0.858 0.598 1.10 0.981 0.732
original_glcm_MaximumProbability -0.11040 0.790 0.936 1.41 0.154 0.722
original_gldm_LargeDependenceHighGrayLevelEmphasis -0.00634 0.714 0.912 1.31 0.562 0.711
original_glcm_JointEnergy -0.02333 0.797 0.863 1.34 0.405 0.710
original_firstorder_Mean -0.17862 0.883 0.519 1.06 0.949 0.702
original_glszm_LargeAreaHighGrayLevelEmphasis 0.21656 1.113 1.284 1.60 0.196 0.700


topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]

theLaVar <- rownames(finalTable)[str_detect(rownames(finalTable),"La_")]

pander::pander(univarDe$orderframe[topLAvar,univariate_columns])
  caseMean caseStd controlMean controlStd controlKSP ROCAUC
original_firstorder_Skewness 0.34095 0.8406 -0.6788 0.9905 0.840 0.780
original_glcm_ClusterShade 0.38451 1.1037 -0.8406 1.4157 0.509 0.755
La_wavelet.LHL_glszm_SmallAreaHighGrayLevelEmphasis -0.02026 0.0403 0.0217 0.0535 0.327 0.754
La_wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation -0.04586 0.1153 0.0685 0.1609 0.131 0.748
La_wavelet.LHL_glrlm_GrayLevelVariance -0.00293 0.0220 0.0154 0.0278 0.671 0.747
La_wavelet.LHL_glszm_GrayLevelNonUniformity 0.00701 0.2067 -0.1680 0.1987 0.923 0.743
La_original_gldm_LargeDependenceHighGrayLevelEmphasis 0.20945 0.4868 0.7224 0.6514 0.496 0.742
wavelet.HLL_glcm_ClusterShade -0.47639 1.3069 0.8844 1.7240 0.538 0.737
wavelet.HLL_firstorder_Skewness -0.30857 0.9039 0.5092 1.0965 0.534 0.736
La_wavelet.LHL_glrlm_RunLengthNonUniformityNormalized -0.01728 0.0600 -0.0925 0.1041 0.114 0.735

dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")

theSigDc <- dc[theLaVar]
names(theSigDc) <- NULL
theSigDc <- unique(names(unlist(theSigDc)))


theFormulas <- dc[rownames(finalTable)]
deFromula <- character(length(theFormulas))
names(deFromula) <- rownames(finalTable)

pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
mean total fraction
2.38 505 0.798


allSigvars <- names(dc)



dx <- names(deFromula)[1]
for (dx in names(deFromula))
{
  coef <- theFormulas[[dx]]
  cname <- names(theFormulas[[dx]])
  names(cname) <- cname
  for (cf in names(coef))
  {
    if (cf != dx)
    {
      if (coef[cf]>0)
      {
        deFromula[dx] <- paste(deFromula[dx],
                               sprintf("+ %5.3f*%s",coef[cf],cname[cf]))
      }
      else
      {
        deFromula[dx] <- paste(deFromula[dx],
                               sprintf("%5.3f*%s",coef[cf],cname[cf]))
      }
    }
  }
}

finalTable <- rbind(finalTable,univarRAW$orderframe[theSigDc[!(theSigDc %in% rownames(finalTable))],univariate_columns])


orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- deFromula[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]

Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores")

finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
  DecorFormula caseMean caseStd controlMean controlStd controlKSP ROCAUC RAWAUC fscores
original_firstorder_Skewness 0.34095 0.8406 -0.6788 0.9905 0.8399 0.780 0.780 NA
original_glcm_ClusterShade 0.38451 1.1037 -0.8406 1.4157 0.5094 0.755 0.755 NA
La_wavelet.LHL_glszm_SmallAreaHighGrayLevelEmphasis -0.712wavelet.LHL_gldm_HighGrayLevelEmphasis -0.325wavelet.LHL_gldm_SmallDependenceHighGrayLevelEmphasis + 1.000*wavelet.LHL_glszm_SmallAreaHighGrayLevelEmphasis -0.02026 0.0403 0.0217 0.0535 0.3268 0.754 0.527 -2
La_wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation -1.066wavelet.HLL_firstorder_InterquartileRange + 1.000wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation -0.04586 0.1153 0.0685 0.1609 0.1312 0.748 0.511 -1
La_wavelet.LHL_glrlm_GrayLevelVariance -0.995wavelet.LHL_firstorder_Variance + 1.000wavelet.LHL_glrlm_GrayLevelVariance -0.00293 0.0220 0.0154 0.0278 0.6714 0.747 0.531 0
La_wavelet.LHL_glszm_GrayLevelNonUniformity -0.901original_shape_VoxelVolume + 1.000wavelet.LHL_glszm_GrayLevelNonUniformity 0.00701 0.2067 -0.1680 0.1987 0.9226 0.743 0.607 -1
La_original_gldm_LargeDependenceHighGrayLevelEmphasis + 4.111original_firstorder_Entropy + 1.000original_gldm_LargeDependenceHighGrayLevelEmphasis -4.008*original_glrlm_RunEntropy 0.20945 0.4868 0.7224 0.6514 0.4962 0.742 0.711 0
wavelet.HLL_glcm_ClusterShade -0.47639 1.3069 0.8844 1.7240 0.5381 0.737 0.737 NA
wavelet.HLL_firstorder_Skewness -0.30857 0.9039 0.5092 1.0965 0.5336 0.736 0.736 NA
La_wavelet.LHL_glrlm_RunLengthNonUniformityNormalized + 1.044wavelet.LHL_glcm_Id -1.156wavelet.LHL_glcm_Idm -0.069*wavelet.LHL_glrlm_RunLengthNonUniformityNormalized -0.01728 0.0600 -0.0925 0.1041 0.1141 0.735 0.645 5
original_gldm_LargeDependenceHighGrayLevelEmphasis NA -0.00634 0.7143 0.9119 1.3129 0.5623 0.711 0.711 NA
wavelet.LHL_glcm_Idm NA -0.07125 0.7556 0.4319 1.0324 0.7425 0.652 0.652 NA
wavelet.LHL_glrlm_RunLengthNonUniformityNormalized NA 0.02091 0.8122 -0.4756 1.0913 0.6558 0.645 0.645 NA
wavelet.LHL_glcm_Id NA -0.09402 0.7630 0.3581 1.0095 0.7605 0.642 0.642 NA
wavelet.LHL_glszm_GrayLevelNonUniformity NA 0.31946 1.0407 0.0222 1.0581 0.0537 0.607 0.607 NA
original_firstorder_Entropy NA 0.12535 0.8512 -0.1937 1.0374 0.8762 0.595 0.595 NA
original_glrlm_RunEntropy NA 0.07473 0.9257 -0.1513 1.0648 0.6074 0.561 0.561 NA
original_shape_VoxelVolume NA 0.34693 1.1224 0.2111 1.1863 0.0343 0.555 0.555 26
wavelet.LHL_gldm_SmallDependenceHighGrayLevelEmphasis NA 0.31677 1.0043 0.2100 1.1022 0.0339 0.546 0.546 NA
wavelet.HLL_firstorder_InterquartileRange NA 0.19819 0.8825 0.0522 1.1175 0.9335 0.543 0.543 NA
wavelet.LHL_gldm_HighGrayLevelEmphasis NA 0.27303 1.0062 0.1879 1.0901 0.0503 0.535 0.535 9
wavelet.LHL_glrlm_GrayLevelVariance NA 0.16333 1.0740 0.3841 1.3676 0.4089 0.531 0.531 NA
wavelet.LHL_glszm_SmallAreaHighGrayLevelEmphasis NA 0.27714 1.0330 0.2238 1.1388 0.0726 0.527 0.527 NA
wavelet.LHL_firstorder_Variance NA 0.16707 1.0789 0.3705 1.3760 0.3153 0.524 0.524 13
wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation NA 0.16546 0.9506 0.1242 1.2083 0.9938 0.511 0.511 NA